#!/bin/sh
# post script for geonode
#
# see: dh_installdeb(1)

set -e

case "$1" in
    remove|deconfigure)
    a2dissite geonode.conf

    rm -rf /var/lib/geonode
    rm -rf /var/www/geonode

    rm -rf /usr/share/geonode/role.sql
    rm -rf /usr/share/geonode/admin.json
    rm -rf /usr/share/geonode/patch*
    rm -rf /usr/bin/geonode
    rm -rf /usr/share/geoserver

    a2ensite 000-default.conf

    invoke-rc.d apache2 start
    invoke-rc.d tomcat8 start
    ;;

    upgrade)
    rm -rf /var/lib/geonode/src
    rm -rf /var/lib/geonode/build
    rm -rf /var/lib/geonode/lib
    ;;
    purge)
        if su - postgres -c 'psql -l | grep -q geonode'
    then
        su - postgres -c 'dropdb geonode_data'
        su - postgres -c 'dropdb geonode'
        su - postgres -c 'dropuser geonode'
    fi
    ;;
    failed-upgrade)
    ;;

    *)
        echo "prerm called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

#DEBHELPER#

exit 0
